#include <iostream>
using namespace std;

int n, m, M;
constexpr int MAXN = 100;
int nums[MAXN];

void solve();
int main() {
    cin >> n >> m;
    for (int i = 0; i < n; i++)
        cin >> nums[i];
    solve();
}

int dp[MAXN][MAXN];
void solve() {
    for (int i = 0; i <= n; i++) dp[i][0] = 1;
    for (int i = 0; i < n; i++)
        for (int j = 1; j <= m; j++) {
            if (j - 1 - nums[i] >= 0)
                dp[i + 1][j] = (dp[i + 1][j - 1] + dp[i][j] - dp[i][j - 1 - nums[i]] + M) % M
            else
                dp[i + 1][j] = dp[i + 1][j - 1] + dp[i][j]
        }
}